package sort;

/**
 * @author LQQ
 * @version V1.0
 * @Package PACKAGE_NAME
 * @date 2020/10/11 15:53
 * @Description
 */
public class BubbleSort {
    public static int[] bubbleSort(int[] array) {
        if (array.length == 0) return array;
        for (int i = 0; i < array.length-1; i++) {
            for(int j=0;j<array.length-i-1;j++){
                if(array[j]>array[j+1]){
                    int  temp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = temp;
                }
            }
        }
        return array;
    }

    public static void main(String[] args) {
        int[] array = new int[]{11,1,3,1,4,7,45,76,23,7,34,9,90,0};
        array = bubbleSort(array);
        for (int num : array){
            System.out.println(num);
        }
    }

}
